﻿<?php 
ob_start();
if(!isset($_SESSION)){
	session_start();
	}
	if(!isset($_SESSION['userName'])){
		header("location:login.php");
	}else{
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>sannhao</title>
    <link rel="Stylesheet" href="css/style.css" type="text/css" />
    <script type="text/javascript" src="js/jquery.js"></script>
		<script type="text/javascript" charset="utf-8">
		$(function(){
			$("select#provine").change(function(){
				$.getJSON("select.php",{id: $(this).val()}, function(j){
					var options = '';
					for (var i = 0; i < j.length; i++) {
						options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
					}
					$("#district").html(options);
					$('#district option:first').attr('selected', 'selected');
				})
			});
			
			$("select#district").change(function(){
				var provine_id = $("#provine").val();
				var district_id = $("#district").val();					
				if((provine_id!="") && (district_id!="")){
				//	alert("provine_id: "+ provine_id + " district_id: "+ district_id);
					$.getJSON("select.php",{provine_id: provine_id, district_id: district_id}, function(j){
						var options = '';
						for (var i = 0; i < j.length; i++) {
						options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
						}
						$("#ward").html(options);
						$('#ward option:first').attr('selected', 'selected');	
					})
				} 
			});				
		})
		</script>  
</head>
<body>
<?php 
if(isset($_POST['next'])){
	if(isset($_POST['address'])&&isset($_POST['provine'])&&isset($_POST['district'])&&isset($_POST['ward'])&&isset($_POST['orientation'])&&isset($_POST['bedroom'])&&isset($_POST['bathroom'])&&isset($_POST['area'])&&isset($_POST['used'])){
	session_register("address");
	$_SESSION["address"] = $_POST['address'];
	
	session_register("provine");
	$_SESSION["provine"] = $_POST['provine'];
	
	session_register("district");
	$_SESSION["district"] = $_POST['district'];
	
	session_register("ward");
	$_SESSION["ward"] = $_POST['ward'];
	
	session_register("orientation");
	$_SESSION["orientation"] = $_POST['orientation'];
	
	session_register("bedroom");
	$_SESSION["bedroom"] = $_POST['bedroom'];
	
	session_register("bathroom");
	$_SESSION["bathroom"] = $_POST['bathroom'];
	
	session_register("area");
	$_SESSION["area"] = $_POST['area'];
	
	session_register("used");
	$_SESSION["used"] = $_POST['used'];
	
	session_register("sohong");
	$_SESSION["sohong"] = $_POST['sohong'];
	
	session_register("sodo");
	$_SESSION["sodo"] = $_POST['sodo'];
	}else{
		echo "Vui lòng điền đầy đủ các thông tin đánh dấu *";//cai nay o layout la nguoc, cho Dang lam css
	}
	
	if(isset($_POST['project'])){		session_register("project");		$_SESSION["project"] = $_POST['project'];	}
	
	if(isset($_POST['yearbuild'])){		session_register("yearbuild");		$_SESSION["yearbuild"] = $_POST['yearbuild'];	}
	
	if(isset($_POST['floor'])){		session_register("floor");		$_SESSION["floor"] = $_POST['floor'];	}
	
	if(isset($_POST['numfloor'])){		session_register("numfloor");		$_SESSION["numfloor"] = $_POST['numfloor'];	}
	
	if(isset($_POST['conditioner'])){		session_register("conditioner");		$_SESSION["conditioner"] = $_POST['conditioner'];	}
	
	if(isset($_POST['gr_moto'])){		session_register("gr_moto");		$_SESSION["gr_moto"] = $_POST['gr_moto'];	}
	
	if(isset($_POST['garage'])){		session_register("garage");		$_SESSION["garage"] = $_POST['garage'];	}
	
	if(isset($_POST['pet'])){		session_register("pet");		$_SESSION["pet"] = $_POST['pet'];	}
	
	if(isset($_POST['gym'])){		session_register("gym");		$_SESSION["gym"] = $_POST['gym'];	}
	
	if(isset($_POST['internet'])){		session_register("internet");		$_SESSION["internet"] = $_POST['internet'];	}
	
	if(isset($_POST['guard'])){		session_register("guard");		$_SESSION["guard"] = $_POST['guard'];	}
	
	if(isset($_POST['htan'])){		session_register("htan");		$_SESSION["htan"] = $_POST['htan'];	}
	
	if(isset($_POST['pool'])){		session_register("pool");		$_SESSION["pool"] = $_POST['pool'];	}
	
	if(isset($_POST['garden'])){		session_register("garden");		$_SESSION["garden"] = $_POST['garden'];	}
	
	if(isset($_POST['detail'])){		session_register("detail");		$_SESSION["detail"] = $_POST['detail'];	}
	
	if(isset($_POST['sohong'])){	session_register("sohong"); $_SESSION["sohong"] = $_POST['sohong'];	}
	
	if(isset($_POST['sodo'])){	session_register("sodo"); $_SESSION["sodo"] = $_POST['sodo'];}
	
	header("location: step3.php");
}else{
?>
<?php require_once("connection/connect.php");?>
    <div class="wrapper">
        <div class="body">
            <div style="margin-bottom: 10px">
                <div style="float: left" class="text-3">
                    Xin chào<?php echo $_SESSION["userName"];?> </div>
          <div style="float: right">
                    <a href="#">Tài khoản</a> | <a href="#">Danh sách của tôi</a> | <a href="#">Thông tin
                        cá nhân</a>
                </div>
                <div class="vide">
                </div>
            </div>
            <div style="margin-bottom: 10px">
                <div style="float: left">
                    <h2>
                        Đăng thông tin nhà tại Sànnhàở.com
                    </h2>
                </div>
                <div style="float: right">
                    <table cellpadding="0" cellspacing="0">
                        <tr>
                            <td>
                                <img alt="" border="0" src="images/step1.gif" />
                            </td>
                            <td>
                                <img alt="" border="0" src="images/step2_orange.gif" />
                            </td>
                            <td>
                                <img alt="" border="0" src="images/step3.gif" />
                            </td>
                            <td>
                                <img alt="" border="0" src="images/step4.gif" />
                            </td>
                            <td>
                                <img alt="" border="0" src="images/step5.gif" />
                            </td>
                        </tr>
                    </table>
                </div>
                <div class="vide">
                </div>
            </div>
            <form action="step2.php" method="post" name="fstep" id="fstep">
            <table cellpadding="0" cellspacing="0" style="width: 100%">
                <tr>
                    <td style="vertical-align: top">
                        <table cellpadding="0" cellspacing="0" style="float: left; width: 470px">
                            <tr>
                                <td class="title-2">
                                    Địa điểm
                                </td>
                            </tr>
                            <tr>
                                <td style="vertical-align: top; padding: 10px 0 10px 0">
                                    <table cellpadding="5" cellspacing="0">
                                        <tr>
                                            <td rowspan="7" style="vertical-align: top">
                                                <img alt="" border="1px" src="images/location.jpg" />                                            </td>
                                            <td class="text-1">
                                                Địa chỉ
                                            :</td>
                                            <td><input id="address" type="text" class="textbox" style="width: 150px" /></td>
                                      </tr>
                                        <tr>
                                            <td class="text-1">
                                                Tỉnh/thành phố                                            </td>
                                            <td>
                                                 <select id="provine" name="provine" class="select" style="width: 150px">
                                                    <option value="">Chọn tỉnh/thành phố</option>
                                                    <?php 
													$rs = mysql_query("select * from provines");
													while($row = mysql_fetch_array($rs)){
													?>
                                                    <option value="<?php echo $row['provine_id'];?>"><?php echo $row['name'];?></option>
                                                    <?php }?>
                                                </select>                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="text-1">
                                                Quận/huyện                                            </td>
                                            <td>
                                                <select id="district" name="district" class="select" style="width: 150px">
                                                    <option value="">Chọn quận/huyện</option>
                                                </select>                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="text-1">
                                                Phường/xã                                            </td>
                                            <td>
                                               <select id="ward" name="ward" class="select" style="width: 150px">
                                                    <option value="" >Chọn phường/xã</option>
                                                </select>                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="text-1">
                                                Hướng nhà                                            </td>
                                            <td>
                                            
                                                <select id="orientation" name="orientation" class="select" style="width: 150px">
                                                <option>Chọn hướng nhà</option>
                                            
                                                    <option value="1">Đông</option>
                                                    <option value="1">Tây</option>
                                                    <option value="1">Nam</option>
                                                    <option value="1">Bắc</option>
                                            
                                                </select>                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="text-1">
                                                Kiểu đường *                                            </td>
                                            <td>
                                                <select id="streettype" name="streettype" class="select" style="width: 150px">
                                                    <option>Chọn kiểu đường</option>
                                                    <option value="1">Đường lớn</option>
                                                    <option value="2">Đường nhỏ</option>
                                                    <option value="3">Đường hẻm</option>
                                          </select>                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="text-1">
                                                Dự án
                                            *</td>
                                            <td>
                                                <input id="project" name="project" type="text" class="textbox" style="width: 150px" />                                            </td>
                                        </tr>
                                    </table>
                              </td>
                            </tr>
                        </table>
                    </td>
                    <td style="vertical-align: top">
                        <table cellpadding="0" cellspacing="0" style="float: right; width: 470px">
                            <tr>
                                <td class="title-2">
                                    Đặc điểm nhà
                                </td>
                            </tr>
                            <tr>
                                <td style="vertical-align: top; padding: 10px 0 10px 0">
                                    <table cellpadding="5" cellspacing="0">
                                        <tr>
                                            <td rowspan="8" style="vertical-align: top">
                                                <img alt="" border="1px" src="images/bed.jpg" />
                                            </td>
                                            <td class="text-1">
                                                Phòng ngủ
                                            </td>
                                            <td>
                                                <input id="bedroom" name="bedroom" type="text" class="textbox" style="width: 80px" />
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="text-1">
                                                Phòng tắm
                                            </td>
                                            <td>
                                                <input id="bathroom" name="bathroom" type="text" class="textbox" style="width: 80px" />
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="text-1">
                                                Tổng diện tích sử dụng
                                            </td>
                                            <td>
                                                <input id="area" name="area" type="text" class="textbox" style="width: 80px" />
                                                m2
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="text-1">
                                                Năm xây dựng
                                            *</td>
                                            <td>
                                                <input id="yearbuild" name="yearbuild" type="text" class="textbox" style="width: 80px" />
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="text-1">
                                                Vị trí tầng
                                            *</td>
                                            <td>
                                                <input id="floor" name="floor" type="text" class="textbox" style="width: 80px" />
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="text-1">
                                                Số tầng (gồm trệt)
                                            *</td>
                                            <td>
                                                <input id="numfloor" name="numfloor" type="text" class="textbox" style="width: 80px" />
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="text-1">
                                                Tình trạng nhà
                                            </td>
                                            <td>
                                                <input id="used" checked="checked" name="used" type="radio" value= '1' />Đã sử dụng
                                                <input id="used" checked="checked" name="used" type="radio" value= '0' />Mới xây
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td colspan="2" class="title-2">
                        Nội dung chi tiết
                    </td>
                </tr>
                <tr>
                    <td colspan="2" style="padding: 10px 0 10px 0">
                        <table cellpadding="5" cellspacing="0">
                            <tr>
                                <td rowspan="5" style="vertical-align: top">
                                    <img alt="" border="1px" src="images/features.jpg" />                                </td>
                                <td colspan="5" class="text-1">
                                    Các tiện ích kèm theo:                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <input id="conditioner" name="conditioner" type="checkbox" />
                                    Máy lạnh
                                *</td>
                                <td>
                                    <input id="gr_moto" name="gr_moto" type="checkbox" />
                                    Có chỗ để xe máy
                                *</td>
                                <td>
                                    <input id="garage" name="garage" type="checkbox" />
                                    Có chỗ để ôtô*                                </td>
                                <td>
                                    <input id="pet" name="pet" type="checkbox" />
                                    Có thể nuôi thú cưng
                                *</td>
                                <td>
                                    <input id="gym" name="gym" type="checkbox" />
                                    Trung tâm thể dục
                                *</td>
                            </tr>
                            <tr>
                                <td>
                                    <input id="internet" name="internet" type="checkbox" />
                                    Internet
                                *</td>
                                <td>
                                    <input id="guard" name="guard" type="checkbox" />
                                    Nhân viên bảo vệ
                                *</td>
                                <td>
                                    <input id="htan" name="htan" type="checkbox" />
                                    Hệ thống an ninh
                                *</td>
                                <td>
                                    <input id="sodo" name="sodo" type="checkbox" />
                                    Sổ đỏ *                               </td>
                                <td>
                                    <input id="sohong" name="sohong" type="checkbox" />
                                    Sổ hồng *                               </td>
                            </tr>
                            <tr>
                                <td>
                                    <input id="pool" name="pool" type="checkbox" />
                                    Hồ bơi
                                *</td>
                                <td>
                                    <input id="garden" name="garden" type="checkbox" />
                                    Vườn
                                *</td>
                            </tr>
                            <tr>
                                <td colspan="5" class="text-1">
                                    Mô tả chi tiết tiếng Việt:*<br />
                                    <textarea id="detail" name="detail" cols="20" rows="2" style="width: 745px; height: 120px"></textarea>                                </td>
                            </tr>
                            <tr align="center">
                              <td colspan="6" style="vertical-align: top">Lưu ý: Những mục đánh dấu * có thể bỏ trống (cái này Đẳng sửa lại css để chỉnh lại)</td>
                            </tr>
                        </table>
                  </td>
                </tr>
            </table>
            <div class="vide">
            </div>
            <div>
                <div style="float: left">
                    <a href="step1.htm">
                        <img alt="" border="" src="images/back_button.jpg" /></a>
                </div>
  <div style="float: right">
                    <input id="next" name="next" type="submit" value="    Next       "/>
                </div>
                <div class="vide">
                </div>
            </div>
            </form>
        </div>
    </div>    
    <?php 
	}
	?>
</body>
</html>
<?php }
ob_end_flush();
?>